home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / c / read.man < prev    next >
Encoding:
Text File  |  1989-01-25  |  4.0 KB  |  133 lines

  1.  
  2.  
  3.  
  4. READ                  C Library Procedures                   READ
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      read, readv - read input
  10.  
  11. SSYYNNOOPPSSIISS
  12.      cccc == rreeaadd((dd,, bbuuff,, nnbbyytteess))
  13.      iinntt cccc,, dd;;
  14.      cchhaarr **bbuuff;;
  15.      iinntt nnbbyytteess;;
  16.  
  17.      ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
  18.      ##iinncclluuddee <<ssyyss//uuiioo..hh>>
  19.  
  20.      cccc == rreeaaddvv((dd,, iioovv,, iioovvccnntt))
  21.      iinntt cccc,, dd;;
  22.      ssttrruucctt iioovveecc **iioovv;;
  23.      iinntt iioovvccnntt;;
  24.  
  25. DDEESSCCRRIIPPTTIIOONN
  26.      _R_e_a_d attempts to read _n_b_y_t_e_s of data from the object refer-
  27.      enced by the descriptor _d into the buffer pointed to by _b_u_f.
  28.      _R_e_a_d_v performs the same action, but scatters the input data
  29.      into the _i_o_v_c_n_t buffers specified by the members of the _i_o_v
  30.      array: iov[0], iov[1], ..., iov[iovcnt-1].
  31.  
  32.      For _r_e_a_d_v, the _i_o_v_e_c structure is defined as
  33.  
  34.           struct iovec {
  35.                caddr_t   iov_base;
  36.                int  iov_len;
  37.           };
  38.  
  39.      Each _i_o_v_e_c entry specifies the base address and length of an
  40.      area in memory where data should be placed. _R_e_a_d_v will
  41.      always fill an area completely before proceeding to the
  42.      next.
  43.  
  44.      On objects capable of seeking, the _r_e_a_d starts at a position
  45.      given by the pointer associated with _d (see _l_s_e_e_k(2)).  Upon
  46.      return from _r_e_a_d, the pointer is incremented by the number
  47.      of bytes actually read.
  48.  
  49.      Objects that are not capable of seeking always read from the
  50.      current position.  The value of the pointer associated with
  51.      such an object is undefined.
  52.  
  53.      Upon successful completion, _r_e_a_d and _r_e_a_d_v return the number
  54.      of bytes actually read and placed in the buffer.  The system
  55.      guarantees to read the number of bytes requested if the
  56.      descriptor references a normal file that has that many bytes
  57.      left before the end-of-file, but in no other case.
  58.  
  59.      If the returned value is 0, then end-of-file has been
  60.  
  61.  
  62.  
  63. Sprite v1.0               May 23, 1986                          1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. READ                  C Library Procedures                   READ
  71.  
  72.  
  73.  
  74.      reached.
  75.  
  76. RREETTUURRNN VVAALLUUEE
  77.      If successful, the number of bytes actually read is
  78.      returned.  Otherwise, a -1 is returned and the global vari-
  79.      able _e_r_r_n_o is set to indicate the error.
  80.  
  81. EERRRROORRSS
  82.      _R_e_a_d and _r_e_a_d_v will fail if one or more of the following are
  83.      true:
  84.  
  85.      [EBADF]        _D is not a valid file or socket descriptor
  86.                     open for reading.
  87.  
  88.      [EFAULT]       _B_u_f points outside the allocated address
  89.                     space.
  90.  
  91.      [EIO]          An I/O error occurred while reading from the
  92.                     file system.
  93.  
  94.      [EINTR]        A read from a slow device was interrupted
  95.                     before any data arrived by the delivery of a
  96.                     signal.
  97.  
  98.      [EINVAL]       The pointer associated with _d was negative.
  99.  
  100.      [EWOULDBLOCK]  The file was marked for non-blocking I/O, and
  101.                     no data were ready to be read.
  102.  
  103.      In addition, _r_e_a_d_v may return one of the following errors:
  104.  
  105.      [EINVAL]       _I_o_v_c_n_t was less than or equal to 0, or
  106.                     greater than 16.
  107.  
  108.      [EINVAL]       One of the _i_o_v__l_e_n values in the _i_o_v array
  109.                     was negative.
  110.  
  111.      [EINVAL]       The sum of the _i_o_v__l_e_n values in the _i_o_v
  112.                     array overflowed a 32-bit integer.
  113.  
  114.      [EFAULT]       Part of the _i_o_v points outside the process's
  115.                     allocated address space.
  116.  
  117. SSEEEE AALLSSOO
  118.      dup(2), fcntl(2), open(2), pipe(2), select(2), socket(2),
  119.      socketpair(2)
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. Sprite v1.0               May 23, 1986                          2
  130.  
  131.  
  132.  
  133.